library DebugToolkit 
    /*! by LuizBills | v1.1.0 */ 

    globals
        private constant real MSG_DURATION = 60 // seconds
        
        private constant string COLOR_LOG = "FFFFFF"
        private constant string COLOR_WARN = "FF851B"
        private constant string COLOR_ERROR = "FF4136"
        
        private constant string PREFIX_LOG = ""
        private constant string PREFIX_WARN = "[WARNING] "
        private constant string PREFIX_ERROR = "[ERROR] "
    endglobals

    struct Debug extends array

        // Displays a normal message
        static method log takes string msg returns nothing
            call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, MSG_DURATION, "|cFF" + COLOR_LOG + PREFIX_LOG + msg + "|r")
        endmethod

        // Displays an warning message
        static method warn takes string msg returns nothing
            debug call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, MSG_DURATION, "|cFF" + COLOR_WARN + PREFIX_WARN + msg + "|r")
        endmethod

        // Displays an error message
        static method error takes string msg returns nothing
            debug call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, MSG_DURATION, "|cFF" + COLOR_ERROR + PREFIX_ERROR + msg + "|r")
        endmethod

        /* Displays an error message if the condition is false
         *
         * @param {boolean} A boolean, which references whether your test passed or failed
         * @param {string} A short description of your test
         *
         * @example
         *    ```
         *    call Debug.assert(1 == 1, "it will never be shown")
         *    call Debug.assert(1 == 0, "it will be shown")
         *    ```
         */
        static method assert takes boolean condition, string msg returns nothing
            if (not condition) then
                call thistype.error(msg)
            endif
        endmethod
        
        /*
        static if DEBUG_MODE then
        static method onInit takes nothing returns nothing
            // test
            call thistype.log("foo")
            call thistype.warn("bar")
            call thistype.error("taz")
        endmethod
        endif
        */
    endstruct

endlibrary